﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using WebExam.Core.Repository;

namespace WebExam.DataEntities
{
    [Table(Name = "dbo.STK")]
    public partial class STK :Entity
    {

        private decimal _stNum;

        private decimal _txNum;

        private string _sttm;

        private string _seleA;

        private string _seleB;

        private string _seleC;

        private string _seleD;

        private string _result;

        private string _analysis;

        private EntityRef<TX> _TX;

        public STK()
        {
            this._TX = default(EntityRef<TX>);
        }

        [Column(Storage = "_stNum", AutoSync = AutoSync.OnInsert, DbType = "Decimal(18,0) NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public decimal STNum
        {
            get
            {
                return this._stNum;
            }
            set
            {
                if ((this._stNum != value))
                {
                    this.SendPropertyChanging("STNum");
                    this._stNum = value;
                    this.SendPropertyChanged("STNum",value);
                }
            }
        }

        [Column(Storage = "_txNum", DbType = "Decimal(18,0)")]
        public decimal TXNum
        {
            get
            {
                return this._txNum;
            }
            set
            {
                if ((this._txNum != value))
                {
                    if (this._TX.HasLoadedOrAssignedValue)
                    {
                        throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
                    }
                    this.SendPropertyChanging("TXNum");
                    this._txNum = value;
                    this.SendPropertyChanged("TXNum",value);
                }
            }
        }

        [Column(Storage = "_sttm", DbType = "VarChar(500)")]
        public string STTM
        {
            get
            {
                return this._sttm;
            }
            set
            {
                if ((this._sttm != value))
                {
                    this.SendPropertyChanging("STTM");
                    this._sttm = value;
                    this.SendPropertyChanged("STTM",value);
                }
            }
        }

        [Column(Storage = "_seleA", DbType = "VarChar(500)")]
        public string SeleA
        {
            get
            {
                return this._seleA;
            }
            set
            {
                if ((this._seleA != value))
                {
                    this.SendPropertyChanging("SeleA");
                    this._seleA = value;
                    this.SendPropertyChanged("SeleA",value);
                }
            }
        }

        [Column(Storage = "_seleB", DbType = "VarChar(500)")]
        public string SeleB
        {
            get
            {
                return this._seleB;
            }
            set
            {
                if ((this._seleB != value))
                {
                    this.SendPropertyChanging("SeleB");
                    this._seleB = value;
                    this.SendPropertyChanged("SeleB",value);
                }
            }
        }

        [Column(Storage = "_seleC", DbType = "VarChar(500)")]
        public string SeleC
        {
            get
            {
                return this._seleC;
            }
            set
            {
                if ((this._seleC != value))
                {
                    this.SendPropertyChanging("SeleC");
                    this._seleC = value;
                    this.SendPropertyChanged("SeleC", value);
                }
            }
        }

        [Column(Storage = "_seleD", DbType = "VarChar(500)")]
        public string SeleD
        {
            get
            {
                return this._seleD;
            }
            set
            {
                if ((this._seleD != value))
                {
                    this.SendPropertyChanging("SeleD");
                    this._seleD = value;
                    this.SendPropertyChanged("SeleD",value);
                }
            }
        }

        [Column(Storage = "_result", DbType = "VarChar(500) NOT NULL", CanBeNull = false)]
        public string Result
        {
            get
            {
                return this._result;
            }
            set
            {
                if ((this._result != value))
                {
                    this.SendPropertyChanging("Result");
                    this._result = value;
                    this.SendPropertyChanged("Result",value);
                }
            }
        }

        [Column(Storage = "_analysis", DbType = "VarChar(800)")]
        public string Analysis
        {
            get
            {
                return this._analysis;
            }
            set
            {
                if ((this._analysis != value))
                {
                    this.SendPropertyChanging("Analysis");
                    this._analysis = value;
                    this.SendPropertyChanged("Analysis",value);
                }
            }
        }

        [Association(Name = "TX_STK", Storage = "_TX", ThisKey = "TXNum", OtherKey = "TXNum", IsForeignKey = true)]
        public TX TX
        {
            get
            {
                return this._TX.Entity;
            }
            set
            {
                TX previousValue = this._TX.Entity;
                if (((previousValue != value)
                            || (this._TX.HasLoadedOrAssignedValue == false)))
                {
                    this.SendPropertyChanging("TX");
                    if ((previousValue != null))
                    {
                        this._TX.Entity = null;
                        previousValue.STK.Remove(this);
                    }
                    this._TX.Entity = value;
                    if ((value != null))
                    {
                        value.STK.Add(this);
                        this._txNum = value.TXNum;
                    }
                    else
                    {
                        this._txNum = default(decimal);
                    }
                    this.SendPropertyChanged("TX",value);
                }
            }
        }
    }
}
